import api from './baseRequest';

// 菜单相关API
export const menuApi = {
  // 获取菜单列表
  getMenuList: async () => {
    try {
      const response = await api.get('/wechat/menu/list');
      return response || [];
    } catch (error) {
      console.error('获取菜单列表失败:', error);
      // 返回模拟数据作为降级方案
      return [];
    }
  },

  // 获取菜单详情
  getMenuDetail: async (id) => {
    try {
      const response = await api.get(`/wechat/menu?menuId=${id}`);
      return response;
    } catch (error) {
      console.error('获取菜单详情失败:', error);
      throw error;
    }
  },

  // 创建自定义菜单
  createCustomMenu: (menuData) => {
    return api.post('/wechat/menu/custom', menuData);
  },

  // 创建个性化菜单
  createConditionalMenu: (menuData) => {
    return api.post('/wechat/menu/conditional', menuData);
  }
};

export default menuApi;